{extend name="common/main"/}

{block name="body"}
    <div class="main-title">
        <h2>
            {present name="data"}[ {$data.title} ] 子{/present}
            {:lang('_MENU_MANAGER_')}
        </h2>
    </div>
    <div class="with-padding">

        <div class="button-box row clearfix ">
            <div class="col-xs-10">
                <a class="btn btn-info" href="{:Url('add',array('pid'=>$pid))}">{:lang('_ADD_WITH_SPACE_')}</a>
                <button class="btn btn-danger ajax-post confirm" url="{:Url('del')}" target-form="ids">{:lang('_DELETE_WITH_SPACE_')}</button>
                <a class="btn btn-warning" href="{:Url('import',array('pid'=>input('get.pid',0)))}">{:lang('_IMPORT_')}</a>
                <button class="btn list_sort" url="{:Url('sort',['pid'=>input('get.pid',0)])}">{:lang('_SORT_')}</button>
            </div>
            <!-- 高级搜索 -->
            <div class="col-xs-2">
                <div class="search-form fr cf">
                    <div class="sleft">
                        <div class="input-group">
                            <input type="text" name="title" class="form-control" value="{:input('title')}"
                                   placeholder="{:lang('_MENU_NAME_INPUT_')}">
                                   <span class="input-group-btn">
                        <a class="btn btn-default" href="javascript:;" id="search" url="{:Url()}">
                            <i class="icon-search"></i>
                        </a></span>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <form class="ids">
            <table class="table table-bordered table-striped table-hover">
                <thead>
                <tr>
                    <th class="row-selected">
                        <input class="checkbox check-all" type="checkbox">
                    </th>
                    <th class="hidden">{:lang('_ID_')}</th>
                    <th>{:lang('_NAME_')}</th>
                    <th>{:lang('_MENU_SUPERIOR_')}</th>
                    <th>{:lang('_GROUP_')}</th>
                    <th>{:lang('_URL_')}</th>
                    <th>{:lang('_SORT_')}</th>
                    <th>{:lang('_DEV_MODE_ONLY_')}</th>
                    <th>{:lang('_WHETHER_TO_HIDE_')}</th>
                    <th>{:lang('_IS_TYPE_MENU_')}</th>
                    <th>{:lang('_OPERATE_')}</th>
                </tr>
                </thead>
                <tbody>
                {notempty name="list"}
                    {volist name="list" id="menu"}
                        <tr>
                            <td><input class="ids row-selected" type="checkbox" name="id[]" value="{$menu.id}"></td>
                            <td class="hidden">{$menu.id}</td>
                            <td>
                                <a href="{:Url('index?pid='.$menu['id'])}">{$menu.title}</a>
                            </td>
                            <td>{$menu.up_title|default=lang('_NONE_')}</td>
                            <td>{$menu.group}</td>
                            <td>{$menu.url}</td>
                            <td>{$menu.sort}</td>
                            <td>
                                <a href="{:Url('toogleDev',array('id'=>$menu['id'],'value'=>abs($menu['is_dev']-1)))}"
                                   class="ajax-get">
                                    {$menu.is_dev_text}
                                </a>
                            </td>
                            <td>
                                <a href="{:Url('toogleHide',array('id'=>$menu['id'],'value'=>abs($menu['hide']-1)))}"
                                   class="ajax-get">
                                    {$menu.hide_text}
                                </a>
                            </td>
                            <td>
                                <a href="#"
                                   class="ajax-get">
                                    {$menu.type_text}
                                </a>
                            </td>
                            <td>
                                <a title="{:lang('_EDIT_')}" href="{:Url('edit?id='.$menu['id'])}">{:lang('_EDIT_')}</a>
                                <a class="confirm ajax-get" title="{:lang('_DELETE_')}" href="{:Url('del?id='.$menu['id'])}">{:lang('_DELETE_')}</a>
                            </td>
                        </tr>
                    {/volist}
                    {else/}
                    <td colspan="10" class="text-center">{:lang('_ADMIN_USER_EMPTY_')}</td>
                {/notempty}
                </tbody>
            </table>
        </form>
        <!-- 分页 -->
        <div class="page">

        </div>
    </div>
{/block}

{block name="script"}
    <script src="__ZUI__/lib/sortable/zui.sortable.min.js"></script>
    <script type="text/javascript">

        $(function () {
            //搜索功能
            $("#search").click(function () {
                var url = $(this).attr('url');
                var query = $('.search-form').find('input').serialize();
                query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
                query = query.replace(/^&/g, '');
                if (url.indexOf('?') > 0) {
                    url += '&' + query;
                } else {
                    url += '?' + query;
                }
                window.location.href = url;
            });
            //回车搜索
            $(".search-input").keyup(function (e) {
                if (e.keyCode === 13) {
                    $("#search").click();
                    return false;
                }
            });
            //导航高亮

            //点击排序
            $('.list_sort').click(function () {
                var url = $(this).attr('url');
                

                if (url != undefined && url != '') {
                    window.location.href = url;
                }
            });
        });
    </script>
{/block}